package com.woniu.aiclient.node;

import com.alibaba.cloud.ai.graph.OverAllState;
import com.alibaba.cloud.ai.graph.action.NodeAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

public class RecordingNode implements NodeAction {

    private static final Logger logger = LoggerFactory.getLogger(RecordingNode.class);

    @Override
    public Map<String, Object> apply(OverAllState state) {

        String feedback = (String) state.value("classifier_output").get();
        System.out.println(state);
        Map<String, Object> updatedState = new HashMap<>();
        if (feedback.contains("with intent")) {
            logger.info("记录有想去类型的意图: {}", feedback);
            updatedState.put("solution", "Praise, no action taken.");
        } else {
            logger.info("记录无想去类型的意图: {}", feedback);
            updatedState.put("solution", feedback);
        }

        return updatedState;
    }
}